package com.tianji.remark.controller;


import com.tianji.remark.domain.dto.LikeRecordFormDTO;
import com.tianji.remark.service.ILikedRecordService;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import lombok.RequiredArgsConstructor;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;
import java.util.Set;

/**
 * <p>
 * 点赞记录表 前端控制器
 * </p>
 *
 * @author WFan
 * @since 2025-03-30
 */
@RestController
@Api(tags = "点赞管理")
@RequestMapping("/likes")
@RequiredArgsConstructor
public class LikedRecordController {

    private final ILikedRecordService likedRecordService;

    /**
     * 点赞或取消
     * @param likeRecordFormDTO
     */
    @PostMapping
    @ApiOperation("点赞/取消点赞")
    public void likeOrCancel(@Valid @RequestBody LikeRecordFormDTO likeRecordFormDTO) {
        likedRecordService.likeOrCancel(likeRecordFormDTO);
    }

    /**
     * 根据业务id集合查询点赞状态
     * @param bizIds
     * @return
     */
    @GetMapping("list")
    @ApiOperation("查询点赞状态")
    public Set<Long> listLikedStatus(@RequestParam List<Long> bizIds){
        return likedRecordService.likedStatus(bizIds);
    }
}
